package com.aaa.project.zhreport.controller;

import com.aaa.framework.web.controller.BaseController;
import com.aaa.framework.web.domain.AjaxResult;
import com.aaa.framework.web.page.TableDataInfo;
import com.aaa.project.zhreport.domain.YwfxFileDownloadRecord;
import com.aaa.project.zhreport.service.YwfxFileDownloadRecordService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author baibin
 * @version 1.0
 * @date 2025/4/10 14:13
 * @description YwfxFileDownloadRecordController
 */
@RestController
@RequestMapping("/file/download/record")
public class YwfxFileDownloadRecordController extends BaseController {

    @Resource
    private YwfxFileDownloadRecordService service;

    @GetMapping("/list")
    public TableDataInfo list(YwfxFileDownloadRecord query){
        startPage();
        List<YwfxFileDownloadRecord> list = service.list(query);
        return getDataTable(list);
    }

    // 根据id下载文件
    @GetMapping("/download/{id}")
    public void download(@PathVariable Long id , HttpServletResponse response){
        service.download(id, response);
    }

    // 根据id删除文件下载记录
    @GetMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable Long id){
        service.delete(id);
        return AjaxResult.success();
    }

}
